$(function(){
	
	$("#btnBukkenList").click(function (evt) {
		
		var type = $("input[name=area]").val() == "0" ? "area" : "line";
		
		var prefCd = $("input[name=PrefCd]").val();
		var cityCd = $("input[name=CityCd]").val();
		var stCd1 = $("input[name=StCd1]").val();
		var stCd2 = $("input[name=StCd2]").val();
		var stCd3 = $("input[name=StCd3]").val(); 
		
		var yachinMax = $("input[name=tinryo]").val() * 10000;
		var madori = $("input[name=madori]").val();
		
		var madoriDef = [];
		madoriDef["1"] = [10];
		madoriDef["2"] = [11];
		madoriDef["3"] = [12,13];
		madoriDef["4"] = [14,15];
		madoriDef["5"] = [20,21];
		madoriDef["6"] = [22,23];
		madoriDef["7"] = [24,25];
		madoriDef["8"] = [30,31];
		madoriDef["9"] = [32,33];
		madoriDef["10"] = [34,35];
		madoriDef["11"] = [40,41];
		madoriDef["12"] = [42,43];
		madoriDef["13"] = [44,45];
		madoriDef["14"] = [50,51,52,53,54,55,60,61,62,63,64,65,70,71,72,73,74,75];
		
		var madoriMinKeys = [];
		
		for(var i = $("input[name=madori]").val(); i <= 14; i ++)
		{
			madoriMinKeys = madoriMinKeys.concat(madoriDef[i]);
		}
		
		var mensekiDef = [];
		
		mensekiDef["1"] = 0;
		mensekiDef["2"] = 15;
		mensekiDef["3"] = 20;
		mensekiDef["4"] = 25;
		mensekiDef["5"] = 30;
		mensekiDef["6"] = 35;
		mensekiDef["7"] = 40;
		mensekiDef["8"] = 45;
		mensekiDef["9"] = 50;
		mensekiDef["10"] = 55;
		mensekiDef["11"] = 60;
		mensekiDef["12"] = 70;
		mensekiDef["13"] = 80;
		mensekiDef["14"] = 90;
		mensekiDef["15"] = 100;
		
		var mensekiMin  = $("input[name=menseki]").val();
		if(mensekiMin != "") mensekiMin = mensekiDef[mensekiMin];
		
		var ekitohoMax = $("input[name=ekitoho]").val();
		
		var ekitohoDef = [];
		
		ekitohoDef["0"] = "";
		ekitohoDef["1"] = 1;
		ekitohoDef["2"] = 5;
		ekitohoDef["3"] = 7;
		ekitohoDef["4"] = 10;
		ekitohoDef["5"] = 15;
		
		if(ekitohoMax != "") ekitohoMax = ekitohoDef[ekitohoMax];
			
	
		//探す条件を作成
		var items = [];
		
		if(type == "area") {
			items.push({name:'target_0', value:prefCd + "-" + cityCd});
		}
		else {
			if( stCd1 != "") items.push({name:'target_0', value:prefCd + "-" + stCd1});
			if( stCd2 != "") items.push({name:'target_1', value:prefCd + "-" + stCd2});
			if( stCd3 != "") items.push({name:'target_2', value:prefCd + "-" + stCd3});
		}
		
		for(var i in madoriMinKeys){
			items.push({name:'madori' + madoriMinKeys[i], value:'on'});
		}
		
		if(yachinMax != "") {
			items.push({name:'tinryo1', value:0});
			items.push({name:'tinryo2', value:yachinMax});
		}
		
		if(mensekiMin != "") {
			items.push({name:'senyu1', value:mensekiMin});
			items.push({name:'senyu2', value:9999999});
		}
		
		if(ekitohoMax != "") {
			items.push({name:'ekitoho', value:ekitohoMax});
		}
		
		items.push({name:'search_type', value:type});
		
		//console.dir(items);
		submit($(this).attr('name') + 'rstobi/rstobi', 'POST', items);
		
	});
});
